#pragma once

#include <string>
#include "stdio.h"
#include <iostream>

class CFile
{
public: /* constructon / destructor */

	CFile()
		{
			fileContents = 0;
			fileSize = 0;
			errorStatus = 0;
		}
	~CFile()
		{
			// std::cout<<"CFile deconstructor called for "<<this<<std::endl;
			clearBuffer();
		}

public: /* public interface calls */

	void			setAsString(std::string value)
					{
						const char* s = value.c_str();
						clearBuffer();
						fileContents = new char [value.size()+1];
						strcpy(fileContents, s);
						fileContents[value.length()] = '\0';
						fileSize = value.length();
					}
	std::string		getAsString()
					{
						return std::string(fileContents);
					}
public:

	std::string		fileName;
	std::string		errMessage;
	char			errorStatus;
	char*			fileContents;
	unsigned int	fileSize;

protected:
	void			clearBuffer()
	{
		if(fileContents)
		{
			delete [] fileContents;
			fileContents = 0;
			fileSize=0;
		}
	}
};